home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / Sleep Deprivation 1.0 Source / Sleep Deprivation ƒ / sd wipes ƒ / Circular wipe.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-12  |  3.4 KB  |  144 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        Circular wipe.c
  4.  
  5. Purpose:    This module handles clearing the screen in a funky
  6.             manner.  See the comments below for more details.
  7.             
  8.  
  9. Sleep Deprivation -- graphic effects on sleep
  10. Copyright (C) 1993 Mark Pilgrim & Dave Blumenthal
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "msg timing.h"
  30.  
  31. #define BlockSize 17
  32. #define CorrectTime 2
  33.  
  34. void CircularWipe(GrafPtr, Pattern*);
  35.  
  36. /* Trace a region from the center to the topleft corner, over <BlockSize> pixels,
  37.    and back to the center.  Fill that in and move the region parameters +BlockSize.
  38.    Repeat for all sides. */
  39.  
  40. void CircularWipe(GrafPtr thePtr, Pattern *thePattern)
  41. {
  42.     RgnHandle    curregion;
  43.     Rect        source;
  44.     int            cx,cy,gap,lastx,lasty;
  45.     int            width,height;
  46.     
  47.     width=thePtr->portRect.right-thePtr->portRect.left;
  48.     height=thePtr->portRect.bottom-thePtr->portRect.top;
  49.     
  50.     cx = (thePtr->portRect.right + thePtr->portRect.left) / 2;
  51.     cy = (thePtr->portRect.bottom + thePtr->portRect.top) / 2;
  52.     
  53.     curregion=NewRgn();
  54.     source.top=source.left=0;
  55.     source.bottom=height;
  56.     source.right=width;
  57.     
  58.     gap=BlockSize;
  59.     lastx=0;
  60.     do                                            /* top quadrant */
  61.     {
  62.         StartTiming();
  63.         SetEmptyRgn(curregion);
  64.         MoveTo(cx,cy);
  65.         OpenRgn();
  66.             LineTo(lastx,0);
  67.             LineTo(gap,0);
  68.             LineTo(cx,cy);
  69.         CloseRgn(curregion);
  70.  
  71.         FillRgn(curregion, *thePattern);
  72.         
  73.         lastx=gap;
  74.         gap+=BlockSize;
  75.         TimeCorrection(CorrectTime);
  76.     }
  77.     while (gap<width+BlockSize);
  78.     
  79.     gap=BlockSize;
  80.     lasty=0;
  81.     do                                            /* right quadrant */
  82.     {
  83.         StartTiming();
  84.         SetEmptyRgn(curregion);
  85.         MoveTo(cx,cy);
  86.         OpenRgn();
  87.             LineTo(width,lasty);
  88.             LineTo(width,gap);
  89.             LineTo(cx,cy);
  90.         CloseRgn(curregion);
  91.  
  92.         FillRgn(curregion, *thePattern);
  93.         
  94.         lasty=gap;
  95.         gap+=BlockSize;
  96.         TimeCorrection(CorrectTime);
  97.     }
  98.     while (gap<height+BlockSize);
  99.     
  100.     lastx=width;
  101.     gap=width-BlockSize;
  102.     do                                            /* bottom quadrant */
  103.     {
  104.         StartTiming();
  105.         SetEmptyRgn(curregion);
  106.         MoveTo(cx,cy);
  107.         OpenRgn();
  108.             LineTo(lastx,height);
  109.             LineTo(gap,height);
  110.             LineTo(cx,cy);
  111.         CloseRgn(curregion);
  112.  
  113.         FillRgn(curregion, *thePattern);
  114.         
  115.         lastx=gap;
  116.         gap-=BlockSize;
  117.         TimeCorrection(CorrectTime);
  118.     }
  119.     while (gap>-BlockSize);
  120.     
  121.     lasty=height;
  122.     gap=height-BlockSize;
  123.     do                                            /* left quadrant */
  124.     {
  125.         StartTiming();
  126.         SetEmptyRgn(curregion);
  127.         MoveTo(cx,cy);
  128.         OpenRgn();
  129.             LineTo(0,lasty);
  130.             LineTo(0,gap);
  131.             LineTo(cx,cy);
  132.         CloseRgn(curregion);
  133.  
  134.         FillRgn(curregion, *thePattern);
  135.         
  136.         lastx=gap;
  137.         gap-=BlockSize;
  138.         TimeCorrection(CorrectTime);
  139.     }
  140.     while (gap>-BlockSize);
  141.     
  142.     DisposeRgn(curregion);
  143. }
  144.